﻿Imports System.Data.SqlClient

Public Class CCTHoaDon
    Dim _iMaHoaDon As Integer
    Dim _iMaMonAn As Integer
    Dim _strNgayLap As String
    Dim _iSoLuong As Integer
    Property MaHoaDon As Integer
        Get
            Return _iMaHoaDon
        End Get
        Set(ByVal value As Integer)
            _iMaHoaDon = value
        End Set
    End Property
    Property MaMonAn As Integer
        Get
            Return _iMaMonAn
        End Get
        Set(ByVal value As Integer)
            _iMaMonAn = value
        End Set
    End Property
    Property NgayLap As String
        Get
            Return _strNgayLap
        End Get
        Set(ByVal value As String)
            _strNgayLap = value
        End Set
    End Property
    Property SoLuong As Integer
        Get
            Return _iSoLuong
        End Get
        Set(ByVal value As Integer)
            _iSoLuong = value
        End Set
    End Property
    Public Function InsertCTHoaDon(ByVal hd As CCTHoaDon) As Integer
        Dim da As New DataProvider
        Try
            da.OpenConnect()
            Dim sql As String = "INSERT INTO CTHOADON(MaHoaDon,MaMonAn,NgayLap, SoLuong) VALUES(@MaHoaDon,@MaMonAn,@NgayLap, @SoLuong)"
            Dim cmd As New SqlCommand(sql, da.con)
            cmd.Parameters.AddWithValue("@MaHoaDon", hd.MaHoaDon)
            cmd.Parameters.AddWithValue("@MaMonAn", hd.MaMonAn)
            cmd.Parameters.AddWithValue("@NgayLap", hd.NgayLap)
            cmd.Parameters.AddWithValue("@SoLuong", hd.SoLuong)
            cmd.ExecuteNonQuery()
            Return 1
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Thông báo")
        Finally
            da.CloseConnect()
        End Try
        Return 0
    End Function
End Class
